package com.lzl.edu.controller;

import com.sun.org.apache.xpath.internal.operations.Mod;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * <h3>lzl_ws</h3>
 * <p>测试控制类</p>
 *
 * @author : 黎钟龙
 * QQ:1661548820
 * Mail：1661548820@qq.com
 * @date : 2022-03-23 21:45
 **/
@Controller
public class TestController {
    @GetMapping("/index")
    public String index(){
        return "index";
    }

    @GetMapping("/test/index")
    public String doRichText(Model model){
        model.addAttribute("Welcome","<h3>欢迎来到index(富文本测试成功)</h3>");
        return "test/index";
    }
//    @GetMapping("/hello")
//    public ModelAndView hello(){
//        ModelAndView mv=new ModelAndView();
//        mv.setViewName("hello");
//        return mv;
//
//    }
    @GetMapping("/hello")
    public String hello(Model model)  {
            System.out.println(1/0);
        return "hello";
    }

    @GetMapping("test/value1")
    public String doTest1(Model model,String valueRre){
        System.out.println(valueRre);
        String view="xxx";
        if (!valueRre.isEmpty()){
//            数据不为空带着数据转发到另一个请求/或方法
            String value="哈哈哈";
            model.addAttribute("v1",value);
            System.out.println(value);
            doTest2(model);
        }
//        数据为空返回视图
        return view;
    }
    @GetMapping("test/value2")
    public String doTest2(Model model){
        String value="啊啊啊啊";
        model.addAttribute("v2",value);
        System.out.println(value);
        return "index";
    }

}
